//
//  CustomContentView.m
//  HLScan
//
//  Created by XTW on 2022/7/12.
//

#import "CustomContentView.h"

@interface CustomContentView() {
    float scaleHorizontal;
    float scaleVertical;
}



@end

@implementation CustomContentView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        scaleHorizontal = (SCREEN_WIDTH_DEVICE - 80)/frame.size.height;
        scaleVertical = frame.size.height/(SCREEN_WIDTH_DEVICE - 80);
    }
    return self;
}

- (void)actionLeftRotate {
    self.horizontal = !self.horizontal;
    float scale = scaleHorizontal;
    if (!self.horizontal) {
        scale = scaleVertical;
    }
    [UIView animateWithDuration:0.3 animations:^{
        self.transform = CGAffineTransformScale(self.transform, scale, scale);
        self.transform = CGAffineTransformRotate(self.transform, -M_PI_2);
    }];
}

- (void)actionRightRotate {
    self.horizontal = !self.horizontal;
    float scale = scaleHorizontal;
    if (!self.horizontal) {
        scale = scaleVertical;
    }
    [UIView animateWithDuration:0.3 animations:^{
        self.transform = CGAffineTransformScale(self.transform, scale, scale);
        self.transform = CGAffineTransformRotate(self.transform, M_PI_2);
    }];
}

@end
